package com.dcyao.musicserve.common;

import lombok.Data;

@Data
public class R {
    private int code;
    private String message;
    private String type;

    private Boolean success;
    private Object data;

    public static R success(String message) {
        R r = new R();
        r.setCode(200);
        r.setMessage(message);
        r.setSuccess(true);
        r.setType("success");
        r.setData(null);
        return r;
    }
    public static R success(String message, Object data) {
        R r = success(message);
        r.setData(data);
        return r;
    }
    public static R error(Integer code, String message) {
        R r = success(message);
        r.setCode(code);
        r.setSuccess(false);
        r.setType("error");
        return r;
    }
}
